<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
String cookieName = "username";
String cookiePass = "password";
Cookie cookies [] = request.getCookies ();
Cookie myCookie = null;
Cookie cooPass = null;
if (cookies != null)
{
	for (int i = 0; i < cookies.length; i++) 
	{
		if (cookies [i].getName().equals (cookieName))
		{
			myCookie = cookies[i];
			break;
		}
	}
	for (int i = 0; i < cookies.length; i++) 
	{
		if (cookies [i].getName().equals (cookiePass))
		{
			cooPass = cookies[i];
			break;
		}
	}
}



%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Show Cookies</title>
</head>
<body>
<%
if (myCookie == null) {
%>
No Cookie found with the name <%=cookieName%>
<%
} else { if (myCookie.getValue() != "") { 
%> 
<p>Username: <%=myCookie.getValue()%>
<%
} else {
%>
<p>Blank Field (Username)
<% }}%>
<br/>
<%
if (cooPass == null) {
%>
No Cookie found with the name <%=cookiePass%>
<%
} else { if (myCookie.getValue() != "") { 
%> 
<p>Password: <%=cooPass.getValue()%>
<%
} else {
%>
<p>Blank Field (Password)
<% }}%>
</body>
</html>